package com.bank.conrtoller;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bank.excption.CommonException;
import com.bank.service.OrganizationService;
/**
 *  机构挂管理类视图
 * @author shan
 *
 */

@Controller
public class OrganizationController extends BaseController{
	
	Logger logger = Logger.getLogger(OrganizationController.class);

	@Autowired
	OrganizationService organizationService;
	
	
	@RequestMapping(value="addOrganization.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> addOrganization(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用增加机构");
		organizationService.saveOrganization(params);
		return this.setAndGetSuccess();		
	}
	
	@RequestMapping(value="updateOrganization.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> updateOrganization(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用更新机构");
		organizationService.updateOrganization(params);
		return this.setAndGetSuccess();
	}
	
	@RequestMapping(value="getOrganizationList.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object>  getOrganizationList(@RequestBody Map<String,Object> params){
		//查询机构列表
		List<Object> value = organizationService.getgetOrganizationList(params);
		Integer total = organizationService.getgetOrganizationListCount(params);
		this.setMapValue("total", total);
		this.setMapListValue("data", value);
		return this.returnMap();
	}
	
}
